home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patches 1995 June / SGI IRIX Patches 1995 Jun.iso / 5.3_patches / patchSG0000415 / patchSG0000415.idb / usr / include / sys / dksc.h.z / dksc.h
Encoding:
C/C++ Source or Header  |  1995-06-12  |  11.5 KB  |  397 lines

  1. /**************************************************************************
  2.  *                                      *
  3.  *          Copyright (C) 1986, Silicon Graphics, Inc.          *
  4.  *                                      *
  5.  *  These coded instructions, statements, and computer programs  contain  *
  6.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  7.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  8.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  9.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  10.  *                                      *
  11.  **************************************************************************/
  12.  
  13. #ident "$Revision: 3.56 $"
  14. #ifndef OTYPCNT
  15. #    include <sys/open.h>    /* for OTYP stuff */
  16. #endif
  17.  
  18. /* SCSI disk minor # breakdown; different for different low level
  19.  * SCSI chip drivers.
  20.  *
  21.  * For wd93 and wd95 controllers:
  22.  *    partition is 4 bits (0-3)
  23.  *    target is 4 bits (4-7)
  24.  *    controller is 7 bits (8-14)
  25.  *    lun is 3 bits (15-17) (only lun 0 supported at this time)
  26.  *
  27.  * For VME SCSI controllers (jaguar)
  28.  *    controller is derived from major #
  29.  *    partition is 4 bits (0-3)
  30.  *    target is 3 bits (4-6)
  31.  *  SCSI channel on controller is 1 bit (7)
  32.  *    lun's are not supported on this controller (only LUN 0 allowed)
  33.  */
  34.  
  35. #define dev_to_softc(adap, targ, lun)    (dkdrv[adap][targ][lun])
  36.  
  37. /*    these allow the dksc driver to work with different logical block size
  38.     devices.  So all raw accesses will be OK; if/when block code is fixed,
  39.     block devices will just start working.
  40. */
  41. #define dkCHKBB(bytes) ((bytes)%dk->dk_blksz)
  42. #define dkBTOBB(bytes) ((bytes)/dk->dk_blksz)    /* truncates! used where caller
  43.     should be checking for short count on return anyway. */
  44. #define dkBBTOB(blks) ((blks)*dk->dk_blksz)    /* truncates! used where caller
  45.     should be checking for short count on return anyway. */
  46.  
  47.  
  48. /* partitions per drive */
  49. #define DK_MAX_PART    16
  50.  
  51. /* values for dk_flags */
  52. #define DK_WRTPROT 1        /* drive is write protected */
  53. #define DK_QUEUE 2        /* queueing allowed to drive */
  54. #define DK_WRITE_VER 4        /* write - verify each command */
  55. #define DK_ERASE_BYPASS 8    /* don't erase prior to a write */
  56. #define DK_MAPUSER 0x10        /* can map user addresses */
  57. #define DK_NEEDSTART 0x20     /* needs a startunit cmd */
  58. #define DK_NO_RETRY  0x40     /* do not retry cmd on error or timeout */
  59. #define    DK_QUIET_BLANK    0x80    /* stop blank media error printouts */
  60.  
  61.  
  62. /* by powers of 2, allows tracking request sizes up to 256 blocks;
  63.  * larger requests are included in last bucket.  This is multiples
  64.  * of blocks for that drive, it is not in terms of any particular
  65.  * block size.  Currently implemented only for dksc scsi disk driver.
  66.  * Returned per drive, not per partition. Only ifdef DEBUG
  67. */
  68. #define NUM_BLK_BUCKETS 9
  69. struct    disk_blkstats    {
  70.     uint bk_reads[NUM_BLK_BUCKETS];
  71.     uint bk_writes[NUM_BLK_BUCKETS];
  72. };
  73.  
  74.  
  75. /*
  76.  * Software state per disk drive.
  77.  */
  78. struct    dksoftc {
  79.     struct volume_header dk_vh;    /* Volume header info */
  80.     struct buf dk_buf; /* Local buffer */
  81.     sema_t     dk_wait;/* Synchronous use waiters */
  82.     struct disk_blkstats *dk_blkstats;    /* i/o stats */
  83.     scsi_request_t *dk_subchan; /* struct scsi_request structures */
  84.     scsi_request_t *dk_freereq; /* list of free scsi_requests */
  85.     u_char     dk_maxq;    /* max depth q has reached; debug; LATER */
  86.     u_char     dk_curq;    /* current number of queued commands */
  87.     ushort     dk_driver;    /* host adapter driver number */
  88.     time_t     dk_iostart;    /* 'start' time for sar measurements */
  89.     uint     *dk_drivecap;    /* drive size as returned by readcapacity
  90.         (2nd word is block size at end of media) */
  91.     uint     dk_blksz;    /* logical (from drive) blocksize of device */
  92.     ushort     dk_openparts[OTYPCNT];    /* map of open partitions (counts
  93.         on DK_MAX_PART being 16 or less), one entry for
  94.         CHR, LYR, BLK, SWP, and MNT */
  95.     ushort     dk_flags;
  96.     lock_t     dk_lock;    /* Lock to protect structure fields */
  97.     u_char     dk_selflags;    /* flags for DIOCSELECT; see DIOCSELFLAGS */
  98.     u_char     dk_qdepth;    /* command queue depth */
  99.     u_char    *dk_inqtyp;    /* devtype from first byte of inquiry data */
  100.     sema_t     dk_sema;    /* controls access to dk_done sema */
  101.     sema_t     dk_done;    /* for synchronous I/O */
  102.     struct iobuf dk_queue;    /* wait queue */
  103.     struct buf *dk_active;    /* active queue */
  104. };
  105.  
  106. /* used for dk_inqtype and dk_drivecap, respectively */
  107. #define DK_INQTYP_SIZE 4
  108. #define DK_DRIVECAP_SIZE 8
  109.  
  110. #define    dk_part(minor)    (minor & (DK_MAX_PART - 1))
  111.  
  112. /*
  113.  * For getting config info to user programs that use nlist (sar, rpc.rstatd)
  114.  */
  115. struct dkscinfo {
  116.     int    maxctlr;
  117.     int    maxtarg;
  118.     int    jagstart;
  119. };
  120.  
  121.  
  122. /*
  123.  * This structure is used by the mode select/get ioctls to determine
  124.  * where the data is to be sent to/recieved from.
  125.  */
  126. struct dk_ioctl_data {
  127.     caddr_t    i_addr;
  128.     u_int    i_len;
  129.     u_char    i_page;        /* Page code is used only on mode select */
  130. };
  131.  
  132. /* Maximum amount of data allowed by an ioctl cmd */
  133. #define MAX_IOCTL_DATA    4096
  134.  
  135. /* These are the possible page codes used by mode sense/get */
  136. #define    ERR_RECOV    0x1
  137. #define    CONN_PARMS    0x2
  138. #define DEV_FORMAT    0x3
  139. #define DEV_GEOMETRY    0x4
  140. #define DEV_FDGEOMETRY    0x5    /* geometry for SMS flexible disks */
  141. #define BLOCK_DESCRIP    0x7    /* TOSHIBA MK156FB only */
  142. #define VERIFY_ERR    0x7    /* SCSI 2 Verify error recovery page */
  143. #define CACHE_SCSI2    0x8    /* SCSI 2 cache control */
  144. #define QUEUE_PARAM    0xA    /* SCSI 2 queue parameters */
  145. #define NOTCH_SCSI2    0xC    /* SCSI 2 notch page */
  146. #define CACHE_CONTR    0x38    /* CDC Wren IV/V/VI drives */
  147. #define ALL        0x3f
  148.  
  149. /* These are the page control field values recognized by the mode sense cmd */
  150. #define CURRENT        0
  151. #define    CHANGEABLE    (0x1 << 6)
  152. #define DEFAULT        (0x2 << 6)
  153. #define SAVED        (0x3 << 6)
  154.  
  155. /*
  156.  * These are the pages of the drive parameter set/get commands.
  157.  * Note that all of the struct should be allocated to the full
  158.  * size of the union, since we determine their sizes at run time,
  159.  * due to the possiblity of different page sizes on different
  160.  * mfg drives.  This is normally done by using ptrs to the structs,
  161.  * and setting them to point to the dk_pages member of a struct mode_sense_data.
  162.  * Any 'extra' bytes won't be changed by programs like fx, but most
  163.  * drives require that the pages being set by a mode select be
  164.  * the correct size and have valid data for bytes that aren't
  165.  * changed (usually retrieved via a mode sense into the same buffer).
  166.  */
  167. union dk_pages {
  168.     struct common {
  169.         u_char    pg_code;
  170.         u_char    pg_len;
  171.         u_char    pg_maxlen[0x100-2];    /* make room for max possible page len */
  172.     } common;
  173.     struct err_recov {
  174.         u_char     e_pgcode;
  175.         u_char    e_pglen;
  176.         u_char    e_err_bits;
  177.         u_char    e_retry_count;
  178.         /* rest are spec'ed in scsi2, not supported by most drives yet */
  179.         u_char    e_rdretry;
  180.         u_char    e_corrspan;
  181.         u_char    e_headoffset;
  182.         u_char    e_strobeoffset;
  183.         u_char    e_rsv0;
  184.         u_char    e_wrretry;
  185.         u_char    e_rsv1;
  186.         u_char    e_recovtime[2];
  187.     } err_recov;
  188.     struct connparms {
  189.         u_char    c_pgcode;
  190.         u_char    c_pglen;
  191.         u_char    c_bfull;
  192.         u_char    c_bempty;
  193.         u_char    c_binacthi;
  194.         u_char    c_binactlo;
  195.         u_char    c_disconhi;
  196.         u_char    c_disconlo;
  197.         u_char    c_reserv[2];
  198.     } cparms;
  199.     struct dev_format {
  200.         u_char    f_pgcode;
  201.         u_char    f_pglen;
  202.         u_char    f_trk_zone[2];
  203.         u_char    f_altsec[2];
  204.         u_char    f_alttrk_zone[2];
  205.         u_char    f_alttrk_vol[2];
  206.         u_char    f_sec_trac[2];
  207.         u_char    f_bytes_sec[2];
  208.         u_char    f_interleave[2];
  209.         u_char    f_trkskew[2];
  210.         u_char    f_cylskew[2];
  211.         u_char    f_form_bits;
  212.         u_char    f_reserved4[3];
  213.     } dev_format;
  214.     struct dev_geometry {    /* page 4 for winchesters */
  215.         u_char    g_pgcode;
  216.         u_char    g_pglen;
  217.         u_char    g_reserved0;
  218.         u_char    g_ncyl[2];
  219.         u_char    g_nhead;
  220.         u_char    g_wrprecomp[3];
  221.         u_char    g_reducewrcur[3];
  222.         u_char    g_steprate[2];
  223.         u_char    g_landing[3];
  224.         u_char    g_reserved1:7;
  225.         u_char    g_spindlesync:1;
  226.         u_char    g_rotatoff;
  227.         u_char    g_reserved2;
  228.         u_char    g_rotatrate[2];
  229.         u_char    g_reserved3[2];
  230.     } dev_geometry;
  231.     struct dev_fdgeometry {    /* page 5 for floppies */
  232.         u_char    g_pgcode;
  233.         u_char    g_pglen;
  234.         u_char    g_trate[2];
  235.         u_char    g_nhead;
  236.         u_char    g_spt;
  237.         u_char    g_bytes_sec[2];
  238.         u_char    g_ncyl[2];
  239.         u_char    g_wprcomp[2];
  240.         u_char    g_wrcurr[2];
  241.         u_char    g_steprate[2];
  242.         u_char    g_steppulsewidth;
  243.         u_char    g_headset[2];
  244.         u_char    g_moton;
  245.         u_char    g_motoff;
  246.         u_char    g_trdy:1;
  247.         u_char    g_ssn:1;
  248.         u_char    g_mo:1;
  249.         u_char    g_reserv0:5;
  250.         u_char    g_reserv1:4;
  251.         u_char    g_stpcyl:4;
  252.         u_char    g_wrprecomp;
  253.         u_char    g_headld;
  254.         u_char    g_headunld;
  255.         u_char    g_pin34:4;
  256.         u_char    g_pin2:4;
  257.         u_char    g_pin4:4;
  258.         u_char    g_pin1:4;    /* pin 1 TEAC, reserved on NCR */
  259.         u_char    g_reserv2[4];
  260.     } dev_fdgeometry;
  261.     struct block_descrip {    /* Toshiba 156 FB only */
  262.         u_char    b_pgcode;
  263.         u_char    b_pglen;
  264.         u_char    b_reserved0;
  265.         u_char    b_bdlen;
  266.         u_char    b_density;
  267.         u_char    b_reserved1[3];
  268.         u_int    b_blen;        /* This is actually a 3 byte val; high
  269.             byte reserved */
  270.     } block_descrip;
  271.     struct verify_err {    /* scsi 2 error recovery params */
  272.         u_char v_pgcode;
  273.         u_char v_pglen;
  274.         u_char rsv0:4,
  275.                eer:1,
  276.                per:1,
  277.                dte:1,
  278.                dcr:1;
  279.         u_char v_retry;
  280.         u_char v_corrspan;
  281.         u_char v_rsv1[5];
  282.         u_char v_recovtime[2];
  283.     } verify_err;
  284.     struct cachescsi2 {    /* scsi 2 cache ctrl page */
  285.         u_char c_pgcode;
  286.         u_char c_pglen;
  287.         u_char c_rsrv:5;
  288.         u_char c_wce:1;
  289.         u_char c_mf:1;
  290.         u_char c_rcd:1;
  291.         u_char c_rdpri:4;
  292.         u_char c_wrpri:4;
  293.         u_char c_predislen[2];
  294.         u_char c_minpre[2];
  295.         u_char c_maxpre[2];
  296.         u_char c_maxpreceil[2];
  297.         u_char c_fsw:1;    /* force seq write; not yet in rev 10H */
  298.         u_char c_rsrv2:1;    /* not yet in rev 10H */
  299.         u_char c_dra:1;    /* disable readahead; not yet in rev 10H */
  300.         u_char c_rsrv3:5;    /* not yet in rev 10H */
  301.         u_char c_numseg;
  302.         u_char c_cachsize[2];    /* cache seg size; not yet in rev 10H */
  303.         u_char c_rsv5;    /* not yet in rev 10H */
  304.         u_char c_ncachsize[3];    /* non-cache seg size; not yet in rev 10H */
  305.     } cachescsi2;
  306.     struct queueparam {    /* scsi 2 queue parameter page */
  307.         u_char q_pgcode;
  308.         u_char q_pglen;
  309.         u_char q_rsrv1:7,
  310.                q_rlec:1;
  311.         u_char q_algorthm_mod:4,
  312.                q_rsrv2:2,
  313.                q_err:1,
  314.                q_disable:1;
  315.         u_char q_eeca:1,
  316.                q_rsrv3:4,
  317.                q_raenp:1,
  318.                q_uaaenp:1,
  319.                q_eaenp:1;
  320.         u_char q_rsrv4;
  321.         u_char q_ready_aen_holdoff[2];
  322.     } queueparam;
  323.     struct notch {    /* info for 'zone bit recorded' devices */
  324.         u_char n_pgcode;
  325.         u_char n_pglen;
  326.         u_char n_nd:1;
  327.         u_char n_lpn:1;
  328.         u_char n_rsv0:6;
  329.         u_char n_rsv1;
  330.         u_char n_maxnotch[2];
  331.         u_char n_actnotch[2];
  332.         u_char n_startbound[2];
  333.         u_char n_endbound[2];
  334.         u_char n_pagesnotched[2];
  335.     } notch;
  336.     struct cachectrl {    /* CDC Wren IV/V/VI cache control */
  337.         u_char c_pgcode;
  338.         u_char c_pglen;
  339.         u_char c_ccen:1, c_wie:1, c_ssm:1, c_ce:1, c_ctsize:4;
  340.         u_char c_prefetch;
  341.         u_char c_maxpre;
  342.         u_char c_maxpremult;
  343.         u_char c_minpre;
  344.         u_char c_minpremult;
  345.         u_char c_reserv[8];
  346.     } cachctrl;
  347. };
  348.  
  349. /* Error recovery flag byte bits for e_err_bits */
  350. #define E_DCR    0x1
  351. #define E_DTE    0x2
  352. #define E_PER    0x4
  353. #define E_RC    0x10
  354. #define E_TB    0x20
  355. #define E_ARRE    0x40
  356. #define E_AWRE    0x80
  357.  
  358. /* The data structure of the mode sense command */
  359. struct mode_sense_data {
  360.     u_char    sense_len;
  361.     u_char    mediatype;
  362.     u_char    wprot:1, reserv0:2, dpofua:1, reserv1:4;
  363.     u_char    bd_len;
  364.     u_char    block_descrip[8];    /* note that this field will NOT be supplied
  365.         by some drives, so that dk_pages data may actually start at this
  366.         offset;  check the bd_len value! */
  367.     union    dk_pages dk_pages;
  368. };
  369.  
  370. /* The structure of the mode select command */
  371. struct mode_select_data {
  372.     u_char    reserv0;
  373.     u_char    mediatype;
  374.     u_char    wprot:1, reserv1:7;
  375.     u_char    blk_len;        /* This will normally be set to 0 */
  376.     union    dk_pages dk_pages;
  377. };
  378.  
  379. struct defect_header {
  380.     u_char    reserved0;
  381.     u_char    format_bits;
  382.     u_char    defect_listlen[2];
  383. };
  384.  
  385. struct defect_entry {
  386.     u_char    def_cyl[3];
  387.     u_char    def_head;
  388.     u_char    def_sector[4];    /* bytes from index, or sector */
  389. };
  390.  
  391. extern int dkmaxq;
  392.  
  393. /* Prototypes */
  394. extern void    dk_unalloc_softc(struct dksoftc *);
  395.  
  396.  
  397.